//
//  KnockDiscountCollectionViewCell.m
//  WhereToTravel
//
//  Created by dlios on 15/10/14.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "KnockDiscountCollectionViewCell.h"

#define W self.contentView.frame.size.width
#define H self.contentView.frame.size.height

@implementation KnockDiscountCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night) name:@"night" object:nil];
        [self createView];
    }
    return self;
}

- (void)createView {
    [super createView];
    self.upImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.upImageView];
    
    self.upLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12];
    self.upLabel.numberOfLines = 0;
    
    self.mistLabel.font = [UIFont systemFontOfSize:11];
    
    self.downLeftLabel.font = [UIFont systemFontOfSize:10];
    
    self.downRightLabel.font = [UIFont systemFontOfSize:12];
    self.downRightLabel.textAlignment = NSTextAlignmentRight;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.upImageView.frame = CGRectMake(W * 0.02, H * 0.02, W * 0.96, H * 0.6);
    self.upLabel.frame = CGRectMake(W * 0.02, H * 0.63, W * 0.96, H * 0.2);
    self.mistLabel.frame = CGRectMake(W * 0.03, H * 0.84, W * 0.94, H * 0.06);
    self.downLeftLabel.frame = CGRectMake(W * 0.02, H * 0.9, W * 0.3, H * 0.1);
    self.downRightLabel.frame = CGRectMake(W * 0.5, H * 0.9, W * 0.45, H * 0.1);
}

- (void)night {
    if ([SingletonNight shareSingletonNight].isSelete == YES) {
        self.upLabel.textColor = [UIColor whiteColor];
        self.mistLabel.textColor = [UIColor whiteColor];
        self.downLeftLabel.textColor = [UIColor whiteColor];
        self.downRightLabel.textColor = [UIColor whiteColor];
    }
    else {
        self.upLabel.textColor = [UIColor blackColor];
        self.mistLabel.textColor = [UIColor blackColor];
        self.downLeftLabel.textColor = [UIColor blackColor];
        self.downRightLabel.textColor = [UIColor blackColor];
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
}

@end
